import {commonParams} from './config.js'
import axios from 'axios'

export function getTopList() {
    const url = '/api/getTopList'
    const data = Object.assign({},commonParams,{
        g_tk: 5381,
        uin: 0,
        platform: 'h5',
        needNewCode: 1,
        _:1505139334814,
        format: 'json',
        inCharset: 'utf-8',
        outCharset: 'utf-8'
    })
    return axios.get(url,{
        params: data
    }).then((res) => {
        return Promise.resolve(res.data)
    })
}

export function getMusicList(topid) {
    const url = '/api/getMusicList'
    const data = Object.assign({},commonParams,{
        topid,
        g_tk: 5381,
        tpl: 3,
        platform: 'h5',
        page: 'detail',
        type: 'top',
        format: 'json',
        _:1505284120093,
        inCharset: 'utf-8',
        outCharset: 'utf-8'
    })
    return axios.get(url,{
        params: data
    }).then((res) => {
        return Promise.resolve(res.data)
    })
}